package com.ruoyi.shop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.Bq;
import com.ruoyi.shop.service.IBqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/shop/bq")
public class BqController extends BaseController
{
    @Autowired
    private IBqService bqService;

    /**
     * 查询标签列表
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bq bq)
    {
        startPage();
        List<Bq> list = bqService.selectBqList(bq);
        return getDataTable(list);
    }

    /**
     * 导出标签列表
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:export')")
    @Log(title = "标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bq bq)
    {
        List<Bq> list = bqService.selectBqList(bq);
        ExcelUtil<Bq> util = new ExcelUtil<Bq>(Bq.class);
        util.exportExcel(response, list, "标签数据");
    }

    /**
     * 获取标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:query')")
    @GetMapping(value = "/{bqId}")
    public AjaxResult getInfo(@PathVariable("bqId") Long bqId)
    {
        return success(bqService.selectBqByBqId(bqId));
    }

    /**
     * 新增标签
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:add')")
    @Log(title = "标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bq bq)
    {
        return toAjax(bqService.insertBq(bq));
    }

    /**
     * 修改标签
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:edit')")
    @Log(title = "标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bq bq)
    {
        return toAjax(bqService.updateBq(bq));
    }

    /**
     * 删除标签
     */
    @PreAuthorize("@ss.hasPermi('shop:bq:remove')")
    @Log(title = "标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bqIds}")
    public AjaxResult remove(@PathVariable Long[] bqIds)
    {
        return toAjax(bqService.deleteBqByBqIds(bqIds));
    }
}
